package com.sudo.boot.admin._sys.my;

import com.sudo.boot.base.pojo.JsonRes;
import com.sudo.boot.mapper.sys.model.bo.my.MyRoleBoChange;
import com.sudo.boot.mapper.sys.model.vo.my.MyRoleVo;
import com.sudo.boot.service.sys_my.MyRoleService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("my-role")
public class MyRoleController {

    @Resource
    private MyRoleService myRoleService;

    /**
     * 切换登录角色 。
     *
     * @param bo 用户信息
     */
    @PostMapping("changeRole")
    public JsonRes<Void> changeRole(@RequestBody @Validated MyRoleBoChange bo) {
        myRoleService.changeRole(bo);
        return JsonRes.ok();
    }

    /**
     * 查询我的用户 。
     */
    @GetMapping("getMyRoleList")
    public JsonRes<List<MyRoleVo>> getMyRoleList() {
        List<MyRoleVo> myRoleVoList =  myRoleService.getMyRoleList();
        return JsonRes.ok(myRoleVoList);
    }

}
